package 统计不是特殊数字的数字数量3233;

import java.util.HashSet;

public class Solution {
    public int nonSpecialCount(int l, int r) {
        int count = 0;
        HashSet<Integer> set = new HashSet<>();
        for (int i = 2; i * i <= r; i++) {
            int j = i * 2;
            while (j <= Math.sqrt(r)) {
                set.add(j);
                j += i;
            }
            if(i * i >= l) {
                if(!set.contains(i)) {
                    count++;
                }
            }
        }
        return r - l + 1 - count;
    }
}
